<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<pre id="console">
This tests that the JavaScript wrapper objects of shadow DOM objects
are not prematurely garbage collected.

</pre>
<script>
if (window.internals) {
    var ps = [];

    for (var i = 0; i < 10; i++) {
        var p = document.createElement('p');
        ps.push(p);

        var shadow = p.attachShadow({mode: 'open'});
        shadow.tattoo = 'I <3 WebKit';
        shadow.innerHTML = '<style>background-color: red;</style><div>Shadow</div>';
        shadow.styleSheets.tattoo = 'I <3 WebKit cssom';
        shadow = null;
    }

    gc();

    for (i = 0; i < ps.length; i++) {
        shouldBe('internals.shadowRoot(ps[' + i + ']).tattoo', '"I <3 WebKit"');
        shouldBe('internals.shadowRoot(ps[' + i + ']).styleSheets.tattoo', '"I <3 WebKit cssom"');
    }
}
</script>
</body>
</html>
